/*
* Copyright (C) 1997-2001 Id Software, Inc.
* 
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
* 
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE.
* 
* See the GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307, USA.
*  
*/

// Created on 27.11.2003 by RST.
// $Id: netchan_t.java,v 1.2 2004/09/22 19:22:09 salomo Exp $
using System;
using Suake2.UI;
namespace Suake2.UI.qcommon
{
	
	public class netchan_t
	{
		public netchan_t()
		{
			InitBlock();
		}
		private void  InitBlock()
		{
			message_buf = new sbyte[Defines.MAX_MSGLEN - 16];
			reliable_buf = new sbyte[Defines.MAX_MSGLEN - 16];
		}
		
		public bool fatal_error;
		
		// was enum {NS_CLIENT, NS_SERVER}
		public int sock;
		
		public int dropped; // between last packet and previous
		
		public int last_received; // for timeouts
		
		public int last_sent; // for retransmits
		
		public netadr_t remote_address = new netadr_t();
		
		public int qport; // qport value to write when transmitting
		
		// sequencing variables
		public int incoming_sequence;
		
		public int incoming_acknowledged;
		
		public int incoming_reliable_acknowledged; // single bit
		
		public int incoming_reliable_sequence; // single bit, maintained local
		
		public int outgoing_sequence;
		
		public int reliable_sequence; // single bit
		
		public int last_reliable_sequence; // sequence number of last send
		
		//	   reliable staging and holding areas
		public sizebuf_t message = new sizebuf_t(); // writing buffer to send to
		// server
		
		//UPGRADE_NOTE: The initialization of  'message_buf' was moved to method 'InitBlock'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
		public sbyte[] message_buf; // leave
		// space for
		// header
		
		//	   message is copied to this buffer when it is first transfered
		public int reliable_length;
		
		//UPGRADE_NOTE: The initialization of  'reliable_buf' was moved to method 'InitBlock'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
		public sbyte[] reliable_buf; // unpcked
		// reliable
		// message
		
		//ok.
		public virtual void  clear()
		{
			sock = dropped = last_received = last_sent = 0;
			remote_address = new netadr_t();
			qport = incoming_sequence = incoming_acknowledged = incoming_reliable_acknowledged = incoming_reliable_sequence = outgoing_sequence = reliable_sequence = last_reliable_sequence = 0;
			message = new sizebuf_t();
			
			message_buf = new sbyte[Defines.MAX_MSGLEN - 16];
			
			reliable_length = 0;
			reliable_buf = new sbyte[Defines.MAX_MSGLEN - 16];
		}
	}
}